import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
//        Scanner in= new Scanner(System.in);
//        String input="";
//        while (in.hasNextLine()){
//            String str =in.nextLine();
//            input= input+str;
//            if(str.equals("exit")){
//                System.out.print(1);
//                break;
//            }
//        }
//        System.out.print(input);
        try {
            CharStream inputStream = new ANTLRFileStream(args[0]);
            mini1Lexer lexer = new mini1Lexer(inputStream);
            CommonTokenStream tokenStream = new CommonTokenStream(lexer);
            mini1Parser parser = new mini1Parser(tokenStream);
            parser.addErrorListener(new errorListener());
            ParseTree tree = parser.compUnit();
            Visitor visitor = new Visitor();
            visitor.visit(tree);
        }catch (Exception T) {
            System.exit(1);
        }

    }
}
